<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" %>
	<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
	<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Tables - Ace Admin</title>

<meta name="description" content="Static &amp; Dynamic Tables" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<!-- bootstrap & fontawesome -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/font-awesome.min.css" />

<!-- page specific plugin styles -->


<!-- ace styles -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.min.css"
	id="main-ace-style" />

<!--[if lte IE 9]>
			<link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-part2.min.css" />
		<![endif]-->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-skins.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-rtl.min.css" />

<!--[if lte IE 9]>
		  <link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- ace settings handler -->
<script
	src="<%=request.getContextPath()%>/ace/assets/js/ace-extra.min.js"></script>

<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

<!--[if lte IE 8]>
		<script src="<%=request.getContextPath()%>/ace/assets/js/html5shiv.min.js"></script>
		<script src="<%=request.getContextPath()%>/ace/assets/js/respond.min.js"></script>
		<![endif]-->
		
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/jquery-treetable/stylesheets/jquery.treetable.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/jquery-treetable/stylesheets/jquery.treetable.theme.default.css">
    <script src="<%=request.getContextPath()%>/ace/assets/js/jquery-2.1.4.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery-treetable/javascripts/src/jquery.treetable.js"></script>
</head>

<body class="no-skin">
	<c:if test="${not empty msg}">
    	<div id="myAlert" class="alert alert-warning">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<strong>警告！</strong>${msg }。
		</div>
	</c:if>

	<div class="page-content">
		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<div class="table-header">菜单管理</div>

							<!-- <div class="dataTables_borderWrap"> -->
							<div>
								<div id="sample-table-2_wrapper"
									class="dataTables_wrapper form-inline no-footer">
									<form action="<%=request.getContextPath()%>/resource"
										method="get" id="drizzt-table">
										<!-- <div class="row">
											<div class="col-xs-6">
												<div id="sample-table-2_filter" class="dataTables_filter">
													<label>Search:<input type="search"
														class="form-control input-sm"
														aria-controls="sample-table-2"></label>
												</div>
											</div>
										</div> -->
										<table
											class="table table-striped table-bordered table-hover dataTable no-footer"
											id="treetable" role="grid"
											aria-describedby="sample-table-2_info">
											<thead>
												<tr role="row">
														<th class="sorting_disabled">名称</th>
														<th class="sorting_disabled">类型</th>
														<th class="sorting_disabled">URL路径</th>
														<th class="sorting_disabled">权限字符串</th>
														<th class="sorting_disabled">操作</th>
												</tr>
											</thead>

											<tbody>
												<c:forEach items="${sysResources}" var="sysResource">
													<tr data-tt-id='${sysResource.id}' <c:if test="${not sysResource.rootNode}">data-tt-parent-id='${sysResource.parent_id}'</c:if>>
															<td>${sysResource.name}</td>
															<td>${sysResource.type}</td>
															<td>${sysResource.url}</td>
															<td>${sysResource.permission}</td>
															<td>
											                    <shiro:hasPermission name="resource:create">
											                        <c:if test="${sysResource.type ne 'button'}">
											                        <a href="${pageContext.request.contextPath}/resource/${sysResource.id}/appendChild">添加子节点</a>
											                        </c:if>
											                    </shiro:hasPermission>
											
											                    <shiro:hasPermission name="resource:update">
											                        <a href="${pageContext.request.contextPath}/resource/${sysResource.id}/update">修改</a>
											                    </shiro:hasPermission>
											                    <c:if test="${not sysResource.rootNode}">
											
											                    <shiro:hasPermission name="resource:delete">
											                        <a class="deleteBtn" href="#" data-id="${sysResource.id}">删除</a>
											                    </shiro:hasPermission>
											                    </c:if>
											                </td>
													</tr>
												</c:forEach>
											</tbody>
										</table>
									</form>
								</div>
							</div>
						</div>
					</div>
					<!-- PAGE CONTENT ENDS -->
				</div>
				<!-- /.col -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.page-content-area -->
	</div>

</body>

<!-- basic scripts -->

<!--[if !IE]> -->
<script type="text/javascript">
	window.jQuery
			|| document
					.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery-2.1.4.min.js'>"
							+ "<"+"/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery1x.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script type="text/javascript">
	if ('ontouchstart' in document.documentElement)
		document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery.mobile.custom.min.js'>"+ "<"+"/script>");
</script>

<script type="text/javascript">
	$(function() {
	    $("#treetable").treetable({ expandable: true }).treetable("expandNode", 1);
	    $(".deleteBtn").click(function() {
	        if(confirm("确认删除吗?")) {
	            location.href = "${pageContext.request.contextPath}/resource/"+$(this).data("id")+"/delete";
	        }
	    });
	});
</script>
<script
	src="<%=request.getContextPath()%>/ace/assets/js/bootstrap.min.js"></script>


</html>
